﻿using System;
using System.Collections.Generic;
using Color = System.Drawing.Color;
using SwinGame;

namespace Gundam_2._0_Alpha.src
{
    public class VoidZones:CharDrawAction
    {
        private Timer timer = Core.CreateTimer();
        private int increment = 5000;
        private List<Sprite> voidList = new List<Sprite>();
        private bool isPlayer;

        public VoidZones(Character c, bool persistant, int row, int colEnd, int count, int lockoutLevel, bool isPlayer)
            : base(c, persistant, row, colEnd, count, lockoutLevel)
        {
            this.isPlayer = isPlayer;
        }

        public override void DoAction(GameController gc)
        {
            if (Core.TimerTicks(timer) == 0)
            {
                IsActive = true;
                Core.StartTimer(timer);
            }

            if (Core.TimerTicks(timer) > increment)
            {
                Sprite tempSprite = Sprites.CreateSprite(Resources.LoadBitmap("voidzone.png"), 5, 2, 100, 100);
                tempSprite.X = Core.Rnd(GlobalConst.ScreenWidth - tempSprite.Width);
                tempSprite.Y = 90 + Core.Rnd(GlobalConst.ScreenHeight - tempSprite.Height - 90);
                voidList.Add(tempSprite);
                increment += 5000;
            }

            foreach (Sprite s in voidList)
                GlobalConst.DmgCheck.CheckDamage(gc.GameStages.Peek().CharList, s, isPlayer, 100, gc, false,0);
        }

        public override void Draw()
        {
            foreach (Sprite s in voidList)
            {
                s.Draw();
                s.UpdateAnimation();
            }
        }

        public override void Reset(GameController gc)
        {
            increment = 5000;
            IsActive = false;
            Core.StopTimer(timer);
            voidList.Clear();
        }
    }
}
